<?php

class m131116_071911_oak extends CDbMigration
{
    public function safeUp()
    {
        $sql = 'ALTER TABLE `{{location}}` ADD `city_id` smallint AFTER `longitude`;
                ALTER TABLE `{{location}}` ADD `distance` smallint AFTER `city_id`;

                ALTER TABLE `{{location}}` ADD INDEX idx_city_id (`city_id`);
                ALTER TABLE `{{location}}` ADD FOREIGN KEY (`city_id`) REFERENCES `{{city}}` (`id`);';

        $this->execute($sql);
    }

    public function safeDown()
    {
        return false;
    }
}